#include <iostream>
#include <fstream>
#include "room.h"

void fillRooms(Room* &firstroom);
void printRooms(Room* &firstroom);


using namespace std;

int main()
{
	Room* firstroom = NULL;

	fillRooms(firstroom);
	printRooms(firstroom);
	
	return 0;
}

void fillRooms(Room* &firstroom)
{
	int occu, maxCap, roomNum;
	Room* nodePtr = NULL;
	Room* previousNode = NULL;
	ifstream inData;

	inData.open("roomID.txt");

	while(!inData.eof())
	{
		inData >> roomNum;
		inData >> maxCap;
		inData >> occu;

		if(!firstroom)
		{
			firstroom = new Room(roomNum, maxCap, occu);
			nodePtr = firstroom;
		}
		else
		{
			previousNode = nodePtr;
			nodePtr = new Room(roomNum, maxCap, occu);
			previousNode->nextroom = nodePtr;
			
		}
	}

	inData.close();
}

void printRooms(Room* &firstroom)
{
	Room* nodePtr = firstroom;

	while(nodePtr)
	{
		cout << "---------------------------\n";
		cout << "Room ID: " << nodePtr->getrID() << endl;
		cout << "Max Cap: " << nodePtr->getrCap() << endl;
		cout << "Occu   : " << nodePtr->getrOcc() << endl;
		cout << "---------------------------\n";
		nodePtr = nodePtr->nextroom;
	}
}







